public class Date {

    public int year;
    public int month;
    public int day;

    public Date(){
        //调用其他构造方法，必须放在第一行
        this(2021,8,8);
        System.out.println("这个是不带参数的构造方法");
    }

    public Date(int y,int m,int d){
        this.year=y;
        this.month=m;
        this.day=d;
    }
    public void printDate(){
        System.out.println(this.year+" "+this.month+" "+this.day+"");
        this.test();
    }

    public static void main(String[] args) {
        Date date1=new Date(2021,5,5);
        date1.printDate();
    }

    public void setDate(int year,int month,int day){
        this.year=year;
        this.month=month;
        this.day=day;
    }

    public void test(){
        System.out.println("测试一下this......");
    }


    public static void main1(String[] args) {
//        Date date1=new Date();
//        date1.setDate(2008,8,8);
//        date1.printDate();
//
//        Date date2=new Date();
//        date2.setDate(2009,9,9);
//        date2.printDate();
//
//        Date date3=new Date();
//        date3.setDate(2010,10,10);
//        date3.printDate();
    }

}
